package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.UpkeepPlanMapper;
import com.gc.business.domain.UpkeepPlan;
import com.gc.business.service.IUpkeepPlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 电梯保养计划 服务层实现
 * 
 * @author hruiyan
 * @date 2020-11-19
 */
@Slf4j
@Service
public class UpkeepPlanServiceImpl extends ServiceImpl<UpkeepPlanMapper, UpkeepPlan> implements IUpkeepPlanService {

    @Override
    public List<UpkeepPlan> list(UpkeepPlan upkeepPlan){
        LambdaQueryWrapper<UpkeepPlan> wrapper = new LambdaQueryWrapper<>();
        if(upkeepPlan != null){
            if(StringUtils.isNotEmpty(upkeepPlan.getPlanId())){
                wrapper.eq(UpkeepPlan::getPlanId, upkeepPlan.getPlanId());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getElevatorId())){
                wrapper.eq(UpkeepPlan::getElevatorId, upkeepPlan.getElevatorId());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getTemplateId())){
                wrapper.eq(UpkeepPlan::getTemplateId, upkeepPlan.getTemplateId());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getUpkeepType())){
                wrapper.eq(UpkeepPlan::getUpkeepType, upkeepPlan.getUpkeepType());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getUpkeepInterval())){
                wrapper.eq(UpkeepPlan::getUpkeepInterval, upkeepPlan.getUpkeepInterval());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getFirstUpkeepTime())){
                wrapper.eq(UpkeepPlan::getFirstUpkeepTime, upkeepPlan.getFirstUpkeepTime());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getRemindDay())){
                wrapper.eq(UpkeepPlan::getRemindDay, upkeepPlan.getRemindDay());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getCreateBy())){
                wrapper.eq(UpkeepPlan::getCreateBy, upkeepPlan.getCreateBy());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getCreateTime())){
                wrapper.eq(UpkeepPlan::getCreateTime, upkeepPlan.getCreateTime());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getUpdateBy())){
                wrapper.eq(UpkeepPlan::getUpdateBy, upkeepPlan.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getUpdateTime())){
                wrapper.eq(UpkeepPlan::getUpdateTime, upkeepPlan.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(upkeepPlan.getRemark())){
                wrapper.eq(UpkeepPlan::getRemark, upkeepPlan.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    /**
     * 联合查询列表
     * @param upkeepPlan1
     * @return
     */
    @Override
    public List<UpkeepPlan> selectUpkeepPlanList(UpkeepPlan upkeepPlan1){
        return baseMapper.selectUpkeepPlanList(upkeepPlan1);
    }

    /**
     * 根据id联合查询
     * @param planId
     * @return
     */
    @Override
    public UpkeepPlan selectUpkeepPlanListById(Long planId){
        return baseMapper.selectUpkeepPlanListById(planId);
    }

    /**
     * 根据电梯ID查询
     * @param elevatorId
     * @return
     */
    @Override
    public UpkeepPlan getByElevatorId(Long elevatorId){
        return baseMapper.getByElevatorId(elevatorId);
    }


}
